class IUP_VBOX
-- Container for composing elements vertically

inherit
	IUP_LINEAL_BOX
		redefine
			set_alignment,
			set_expand_children,
			set_size,
			set_raster_size
		end
	
create {ANY}
	vbox_empty,
   vbox

feature {ANY}
	
	vbox_empty
	   -- Create an empty vbox
		local
			p, a_vbox: POINTER
		do
			a_vbox := int_vbox_empty (p)
			set_widget(a_vbox)
		end
		
	vbox (col: ARRAY[IUP_WIDGET])
	   -- Create a new vbox containing the list of widgets
		local
         iterator: ITERATOR[IUP_WIDGET]; i: INTEGER; arg: NATIVE_ARRAY[POINTER]; s: IUP_WIDGET; a_vbox: POINTER
		do
			i := col.count
			arg := arg.calloc(i)
			iterator := col.new_iterator
			i := 0
			
			from
				iterator.start
         until
				iterator.is_off
         loop
            s := iterator.item
            arg.put(s.widget, i)
				iterator.next
            i := i + 1
         end

			a_vbox := int_vbox (arg.to_external)
			set_widget(a_vbox)
		end

	-- Attributes

	set_alignment (value: STRING)
		-- (non inheritable): Horizontally aligns the elements. Possible
		-- values: "ALEFT", "ACENTER", "ARIGHT". Default: "ALEFT".
		do
			Precursor (value)
		end

	set_expand_children (state: BOOLEAN)
		-- (non inheritable): forces all children to expand horizontally and to 
		-- fully occupy its space available inside the box. Default: "NO". This 
		-- has the same effect as setting EXPAND=HORIZONTAL on each child.
		do
			Precursor (state)
		end

	set_size (width: INTEGER; height: INTEGER)
		-- (non inheritable): Defines the width of the box. Height will be
		-- ignored. When consulted behaves as the standard SIZE attribute.
		do
			Precursor (width, height)
		end

	set_raster_size (width: INTEGER; height: INTEGER)
		-- (non inheritable): Defines the width of the box. Height will be
		-- ignored. When consulted behaves as the standard RASTERSIZE attribute.
		do
			Precursor (width, height)
		end

feature {}

	-- Internals
	
	int_vbox_empty (arguments: POINTER): POINTER
		external "plug_in"
      alias "{
         location: "${sys}/plugins"
         module_name: "iup"
         feature_name: "IupVbox"
         }"
      end
	
   int_vbox (arguments: POINTER): POINTER
		external "plug_in"
      alias "{
         location: "${sys}/plugins"
         module_name: "iup"
         feature_name: "IupVboxv"
         }"
      end

	-- Validation

	is_valid_alignment (value: STRING): BOOLEAN
		do
			if value.is_equal("ALEFT") or
				value.is_equal("ACENTER") or
				value.is_equal("ARIGHT") then
				Result := True
			else
				Result := False
			end
		end
	
end -- class IUP_VBOX

-- The MIT License (MIT)

-- Copyright (c) 2016 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
